local tanbei = fk.CreateSkill {

  name = "joy__tanbei",

  tags = {  },

}



tanbei:addEffect("active", {
  name = "joy__tanbei",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(tanbei.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player.id
  end,
  on_use = function(self, room, use)
    local player = room:getPlayerById(use.from)
    local target = room:getPlayerById(use.tos[1])
    local choices = {"joy__tanbei2"}
    if not target:isNude() then
      table.insert(choices, 1, "joy__tanbei1")
    end
    local choice = room:askForChoice(target, choices, tanbei.name)
    local targetRecorded = type(player:getMark(choice.."-turn")) == "table" and player:getMark(choice.."-turn") or {}
    table.insertIfNeed(targetRecorded, target.id)
    room:setPlayerMark(player, choice.."-turn", targetRecorded)
    if choice == "joy__tanbei1" then
      local id = room:askForCardChosen(player,target,"hej",tanbei.name,"选择"..Fk:translate(target.general).."区域内的一张牌获得之")
      room:obtainCard(player, id, false, fk.ReasonPrey)
    end
  end,
})

tanbei:addEffect("prohibit", {
  name = "#joy__tanbei_prohibit",
  is_prohibited = function(self, from, to, card)
    return table.contains(from:getTableMark( "joy__tanbei1-turn"), to.id)
  end,
})

tanbei:addEffect("targetmod", {
  name = "#joy__tanbei_targetmod",
  bypass_times = function(self, player, skill, scope, card, to)
    return to and table.contains(player:getTableMark( "joy__tanbei2-turn"), to.id)
  end,
  bypass_distances =  function(self, player, skill, card, to)
    return to and table.contains(player:getTableMark( "joy__tanbei2-turn"), to.id)
  end,
})

return tanbei